<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>下单客户管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/favicon.ico">
    <link rel="stylesheet" href="/resources/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/resources/css/public.css" media="all" />
    <link rel="stylesheet" href="/resources/layui_ext/dtree/dtree.css" media="all" />
    <link rel="stylesheet" href="/resources/layui_ext/dtree/font/dtreefont.css" media="all" />

</head>
<body class="childrenBody">
<!-- 查询条件开始 -->
<blockquote class="layui-elem-quote">
    <form action="" method="post" id="searchFrm" lay-filter="searchFrm" class="layui-form layui-form-pane">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label" style="width: 120px">输出中心</label>
                <div class="layui-input-inline">
                    <input type="text" id="selectouput" name="outPutCenter" autocomplete="off"  class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width: 120px">下单公司</label>
                <div class="layui-input-inline">
                    <input type="text" name="groupName"    autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" style="width: 80px">审核人</label>
                <div class="layui-input-inline">
                    <input type="text" name="authorUser" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-inline">
                    <input type="tel" name="startTime" id="startTime" readonly="readonly" placeholder="yyyy-MM-dd HH:mm:ss"  class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">结束时间</label>
                <div class="layui-input-inline">
                    <input type="tel" name="endTime"  id="endTime" readonly="readonly" placeholder="yyyy-MM-dd HH:mm:ss"  class="layui-input">
                </div>
            </div>

            <div class="layui-inline" style="text-align: center;">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="doSearch"><span class="layui-icon layui-icon-search"></span>查询</button>
                <button type="reset" class="layui-btn layui-btn-warm"><span class="layui-icon layui-icon-refresh-1"></span>重置</button>
            </div>
        </div>

    </form>
</blockquote>
<!-- 查询条件结束-->


<!-- 数据表格开始 -->
<div>
    <table class="layui-hide" id="roleTable" lay-filter="roleTable"></table>

</div>
<div style="display: none;" id="selectOutPutCenterDiv">
    <ul id="outputTree" class="dtree" data-id="0" ></ul>
</div>

<!-- 数据表格结束 -->



<script type="text/javascript" src="/resources/layui/layui.js"></script>
<script type="text/javascript">
    layui.extend({
        dtree: '/resources/layui_ext/dtree/dtree'   // {/}的意思即代表采用自有路径，即不跟随 base 路径
    }).use(['jquery','form','table','layer','dtree','laydate'],function(){
        var $=layui.jquery;
        var form=layui.form;
        var table=layui.table;
        var layer=layui.layer;
        var dtree = layui.dtree;
        var laydate = layui.laydate;
        //初始化富文本

        var curtime = getyyyyMMdd() + " 00:00:00";
        var curtimeend = getyyyyMMdd() + " 23:59:59";

        // console.log(curtime);
        laydate.render({
            elem:'#startTime',
            type:'datetime',
            value:curtime,

        })
        laydate.render({
            elem:'#endTime',
            type:'datetime',
            value:curtimeend,
        })

        var tableIns=table.render({
            elem: '#roleTable'
            ,url:'/firstOrderinfo/getFirstList'
            ,toolbar: '#roleToolBar' //开启头部工具栏，并为其绑定左侧模板
            ,title: '客户数据表'
            ,height:'full-120'
            ,page: true
            ,limit:50
            ,limits:[50,100,150]
            ,cols: [ [
                {field:'foManufacturerName', title:'输出中心',align:'center',width:'150'}
                ,{field:'groupName', title:'下单公司',align:'center',width:'200'}
                ,{field:'founderPhone', title:'企业手机号',align:'center',width:'150'}
                ,{field:'gpPolicyAddr', title:'公司地址',align:'center',width:'250'}
                ,{field:'authorUser', title:'公司审核人',align:'center',width:'250'}
                ,{field:'foDate', title:'首次下单时间',align:'center',width:'200'}

            ] ]
        });

        //模糊查询
        form.on("submit(doSearch)",function(data){
            tableIns.reload({
                where:data.field,
                page:{
                    curr:1
                }
            });
            return false;
        });

        $("#doReset").click(function () {

            $("#dataFrm")[0].reset();

        })

        $("#selectouput").on("click",function(){
            selectOutput();
        })


        //打开选择输出中心
        function selectOutput(data) {

            mainIndex = layer.open({
                type: 1,
                content: $("#selectOutPutCenterDiv"),
                area: ['400px', '300px'],
                title: '选择输出中心',
                btn: ['<span class=layui-icon>&#xe654;确认</span>', '<span class=layui-icon>&#x1006;取消</span>'],
                yes: function (index, layero) {
                    var permissionData = dtree.getCheckbarNodesParam("outputTree");
                    // console.log(params);
                    var params = "";
                    var i = 0;
                    for (i = 0; i < permissionData.length; i++)
                        params += permissionData[i].context + ",";

                    $("#selectouput").val(params.substr(0,params.length - 1));
                    layer.close(mainIndex);

                },
                btn2: function (index, layero) {

                },
                btnAlign: "c",
                success: function () {
                    //根据角色ID请求角色的菜单和权限树 json 数据
                    dtree.render({
                        elem: "#outputTree",
                        dataStyle: "layuiStyle",  //使用layui风格的数据格式
                        dataFormat: "list",  //配置data的风格为list
                        response: {message: "msg", statusCode: 0},  //修改response中返回数据的定义
                        url: "/organization/getAllOuputCenter?",
                        checkbar: true,
                        checkbarType: "all" // 默认就是all，其他的值为： no-all  p-casc   self  only
                    });

                }
            });
        }

        function getyyyyMMdd(){
            var d = new Date();
            var curr_date = d.getDate();
            var curr_month = d.getMonth() + 1;
            var curr_year = d.getFullYear();
            String(curr_month).length < 2 ? (curr_month = "0" + curr_month): curr_month;
            String(curr_date).length < 2 ? (curr_date = "0" + curr_date): curr_date;
            var yyyyMMdd = curr_year + "-" + curr_month +"-"+ curr_date;
            return yyyyMMdd;
        }
        //监听工具条的事件
        /*table.on("toolbar(roleTable)",function(obj){
            switch(obj.event){
                case 'add':
                    openAddLayer();
                    break;
            };
        });*/

        //监听行工具条的事件
       /* table.on("tool(roleTable)",function(obj){
            var data = obj.data; //获得当前行数据
            switch(obj.event){
                case 'update':
                    openUpdateRoleLayer(data);
                    break;
                case 'charge':
                    charge(data);
                    break;
            };
        });*/


    });
</script>

</body>
</html>